<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>使用transition组件结合transition属性实现过渡效果</title>
    <!--引入Vue库-->
    <script src="vue.js"></script>
    <style>
      /* 可以设置不同的进入和离开动画 */
      /* 设置持续时间和动画*/
      .fade-enter {
        opacity: 0;
      }
      .fade-enter-active {
        transition: opacity 0.5s;
      }
      .fade-leave-active {
        transition: transform 0.5s;
      }
      .fade-leave-to {
        transform: translateX(10px);
      }
    </style>
  </head>
  <body>
    <div id="app">
      <button v-on:click="show=!show">
        <span v-if="show">隐藏</span>
        <span v-else>显示</span>
      </button>
      <transition name="fade">
        <p v-if="show">&nbsp;&nbsp;欢迎登录</p>
      </transition>
    </div>
    <script>
      var vm = new Vue({
        el: "#app",
        data: {
          show: true,
        },
      });
    </script>
  </body>
</html>
